//
//  MCLogisticsCell.swift
//  StoreManage
//
//  Created by MC on 2017/12/26.
//  Copyright © 2017年 MC. All rights reserved.
//

import UIKit

class MCLogisticsCell: UITableViewCell {

    var row = 0
    
    
    var model : MCLogisticsModel = MCLogisticsModel() {
        
        didSet {
            detailLabel.text = model.remark
            timeLabel.text = model.datetime
        }
    }
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        backgroundColor = UIColor.white
        
        self.addSubview(lineThreeView)
        lineThreeView.snp.remakeConstraints { (make) ->Void in
            make.right.bottom.equalTo(self)
            make.height.equalTo(1)
            make.left.equalTo(50)
        }
        
        self.addSubview(signButton)
        signButton.snp.remakeConstraints { (make) ->Void in
            make.centerY.equalTo(self)
            make.centerX.equalTo(self.snp.left).offset(25)
            make.size.equalTo(CGSize.init(width: 20, height: 20))
        }
        
        self.addSubview(lineOneView)
        lineOneView.snp.remakeConstraints { (make) ->Void in
            make.centerX.equalTo(signButton)
            make.top.equalTo(self)
            make.width.equalTo(1)
            make.bottom.equalTo(signButton.snp.top)
        }
        self.addSubview(lineTwoView)
        lineTwoView.snp.remakeConstraints { (make) ->Void in
            make.centerX.equalTo(signButton)
            make.bottom.equalTo(self)
            make.width.equalTo(1)
            make.top.equalTo(signButton.snp.bottom)
        }

        self.addSubview(timeLabel)
        timeLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(50)
            make.bottom.equalTo(-10)
        }
        
        self.addSubview(detailLabel)
        detailLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(50)
            make.right.equalTo(-10)
            make.top.equalTo(10)
            make.bottom.lessThanOrEqualTo(timeLabel.snp.top).offset(-10)
        }
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        if self.row == 0 {
            lineOneView.isHidden = true
            signButton.isSelected = true
            detailLabel.textColor = UIColor.MCMain
            timeLabel.textColor = UIColor.MCMain
        } else {
            lineOneView.isHidden = false
            signButton.isSelected = false
            detailLabel.textColor = UIColor.MCGray
            timeLabel.textColor = UIColor.MCGray
        }
    }
    
    lazy var signButton: UIButton = {
        let button = UIButton.init(type: UIButtonType.custom)
        button.setImage(MCImage_createdFormColor(color: UIColor.MCGray_light), for: UIControlState.normal)
        button.setImage(#imageLiteral(resourceName: "Reuse_selectedSign"), for: UIControlState.selected)
        return button
    }()
    
    lazy var lineOneView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.MCGray_light
        return view
    }()
    
    lazy var lineTwoView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.MCGray_light
        return view
    }()

    
    lazy var lineThreeView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.MCGray_light
        return view
    }()

    public lazy var detailLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.MCGray
        label.numberOfLines = 0
        return label
    }()
    
    
    public lazy var timeLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(12)
        label.textColor = UIColor.MCGray
        return label
    }()
}
